<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>选做题1</title>
</head>
<body>
    <div id="信息"></div>
    <script>
        const xhr = new XMLHttpRequest();
        xhr.open('GET', 'http://124.220.159.29:8089/user/getUsersByName?'+'name=胡');
        xhr.send();
        const result = document.getElementById('信息');
        xhr.onreadystatechange = function() {
         if (xhr.readyState === 4) {
        const response = JSON.parse(xhr.responseText);
        response.forEach(function(person) {
        const personElement = document.createElement('div');
        personElement.classList.add('person');
        
        const nameElement = document.createElement('h2');
        nameElement.textContent = person.name;
        personElement.appendChild(nameElement);
        
      const passwordElement = document.createElement('p');
      passwordElement.textContent = 'password: ' + person.password;
        personElement.appendChild(passwordElement);
        
      const genderElement = document.createElement('p');
      genderElement.textContent = 'gender: ' + person.gender;
        personElement.appendChild(genderElement);
        
      const introductionElement = document.createElement('p');
      introductionElement.textContent = 'introduction: ' + person.introduction;
      personElement.appendChild(introductionElement);

      const goodAtElement = document.createElement('p');
      goodAtElement.textContent = 'goodAt: ' + person.goodAt;
      personElement.appendChild(goodAtElement);

      document.body.appendChild(personElement);
       //result.innerHTML=xhr.response;
                });
                }
                };
    </script>

</body>
</html>